<template>
	<view>
		<image src="../../static/images/index_search.png"></image>
		<button  @click="getUserInfo" class="login_btn">授权登录</button>

	</view>
</template>

<script>
	export default{
		data(){
			return{
				appid:'wxcd4855e9ae3ed09d',
				secret:'c27f8498e7db4114e048ffca36c125a4',
				code:''
			}
		},
		onLoad() {
			uni.getSetting({
				success(res){
					if(res.authSetting['scope.userInfo'])
						console.log("登录了")
					else
						console.log("未登录")
						console.log(res.authSetting)
				}
			})
		},
		methods:{
			getUserInfo(){			    
			    uni.getUserProfile({
			        desc:'Wexin',     
			        success:res=>{
						uni.setStorage({
							key:"url",
							data:res.userInfo.avatarUrl
						}),
						uni.setStorage({
							key:"name",
							data:res.userInfo.nickName
						})
						/*uni.navigateTo({
							url:'/pages/index/index'
						})*/
						uni.switchTab({
							url:'/pages/index/index'
						})
			           }
			            })
			        }		
		},
		}
	
</script>

<style lang="less">
	image{
		position:absolute;
		width:100%;
		height:100%;
	}
	.login_btn{
		background-image: linear-gradient(-225deg, #B6CEE8 0%, #F578DC 100%);
		width:200px;
		height:50px;
		border-radius:10px;
		color:#000000;
		top:400px;
		font-weight:500;
	}
</style>
